import java.util.*;

public class Main {
    private static class Pair {
        int x1, x2;
        long num;

        public Pair(int x1, int x2, long num) {
            this.x1 = x1;
            this.x2 = x2;
            this.num = num;
        }

        public int getKey() {
            return x1;
        }

        public int getValue() {
            return x2;
        }

        public long getNum() {
            return num;
        }
    }

    public static int compare1(Pair a, Pair b) {
        if (a.getNum() - b.getNum() > 0) return 1;
        if (a.getNum() - b.getNum() < 0) return -1;
        else return 0;
    }

    public static void main124(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long ret = Integer.MAX_VALUE;
        long[] in = new long[1010];
        long[] sum = new long[1010];
        for (int i = 1; i <= n; i++) {
            in[i] = scan.nextInt();
            sum[i] = sum[i - 1] + in[i];
        }
        List<Pair> l = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                l.add(new Pair(i, j, sum[j] - sum[i - 1]));
            }
        }
        Collections.sort(l, (a, b) -> compare1(a, b));
        for (int i = 0; i < l.size() - 1; i++) {
            long num = Math.abs(l.get(i).getNum() - l.get(i + 1).getNum());
            if (ret > num && (l.get(i).getKey() > l.get(i + 1).getValue() || l.get(i).getValue() < l.get(i + 1).getKey())) {
                ret = num;
            }
        }
        System.out.print(ret);
        scan.close();
    }

    public static void main13245531(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong() / 1000;
        long a = 365 * 24 * 60 * 60;
        long b = 24 * 60 * 60;
        int count = 0;
        while (n > a) {
            n -= a;
            count++;
            if (count % 4 == 0) n -= b;
        }
        while (n > b) {
            n -= b;
        }
        int i = 1;
        while (n >= i * 60 * 60) i++;
        n -= (--i) * 60 * 60;
        if (i == 0)
            System.out.print("00");
        else if (i < 10) {
            System.out.print('0');
            System.out.print(i);
        } else System.out.print(i);
        System.out.print(':');
        i = 1;
        while (n >= i * 60) i++;
        n -= (--i) * 60;
        if (i == 0)
            System.out.print("00");
        else if (i < 10) {
            System.out.print('0');
            System.out.print(i);
        } else System.out.print(i);
        System.out.print(':');
        if (n < 10) {
            System.out.print('0');
            System.out.print(i);
        } else if (n == 0) {
            System.out.print("00");
        } else {
            System.out.print(n);
        }
        scan.close();
    }

    //    public static void main(String[] args) {
//        Scanner scan = new Scanner(System.in);
//        int n = scan.nextInt();
//        int[] in = new int[1000000000];
//        in[0] = 1;
//        if(n == 1){
//            System.out.print(1);
//            return;
//        }
//        int i = 1;
//        int sum = 1;
//        long ret = 1;
//        boolean flag = true;
//        while(flag){
//            sum++;
//            for(int j = sum - 1;j >= 1;j--){
//                in[j] = in[j] + in[j - 1];
//                if(in[j] == n){
//                    System.out.print(ret + j + 1);
//                    flag = false;
//                    break;
//                }
//            }
//            ret += sum;
//        }
//        scan.close();
//    }
/*    public static void qsort(int[] nums, int l, int r)
    {
        if(l >= r) return;
        // 数组分三块
        int key = nums[(l + r)/2];
        int left = l - 1, right = r + 1, i = l;
        while(i < right)
        {
            if(nums[i] < key) swap(nums, ++left, i++);
            else if(nums[i] == key) i++;
            else swap(nums, --right, i);
        }
        // [l, left] [left + 1, right - 1] [rigth, r]
        qsort(nums, l, left);
        qsort(nums, right, r);
    }


    public static void swap(int[] in, int i, int j) {
        int tmp = in[i];
        in[i] = in[j];
        in[j] = tmp;
    }*/

        public static void qsort1(int[] nums, int l, int r)
    {
        if(l >= r) return;
        int key = nums[(l + r)/2];
        int left = l - 1, right = r + 1, i = l;
        while(i < right)
        {
            if(nums[i] < key) swap(nums, ++left, i++);
            else if(nums[i] == key) i++;
            else swap(nums, --right, i);
        }
        qsort1(nums, l, left);
        qsort1(nums, right, r);
    }
    public static void qsort2(int[] nums, int l, int r)
    {
        if(l >= r) return;
        int key = nums[(l + r)/2];
        int left = l - 1, right = r + 1, i = l;
        while(i < right)
        {
            if(nums[i] > key) swap(nums, ++left, i++);
            else if(nums[i] == key) i++;
            else swap(nums, --right, i);
        }
        qsort2(nums, l, left);
        qsort2(nums, right, r);
    }
    public static void swap(int[] in, int i, int j) {
        int tmp = in[i];
        in[i] = in[j];
        in[j] = tmp;
    }

    public static void main12(String[] args) {
        int[] in = {3,1,2,0};
        qsort1(in,0,3);
        for(int i : in) System.out.print(i);
        System.out.println();
        qsort2(in,0,3);
        for(int i : in) System.out.print(i);
    }
    public static void main153(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] in = new int[n];
        int[][] num = new int[n][2];
        for(int i = 1;i <= n;i++){
            num[i-1][0] = scan.nextInt();
            num[i-1][1] = scan.nextInt();
            in[i-1] = i;
        }
        for(int i = 0;i < m;i++){
            if(num[i][0] == 1){
                qsort1(in,num[i][1]-1,in.length-1);
            }else{
                qsort2(in,0,num[i][1] - 1);
            }
        }
        for(int i : in){
            System.out.print(i);
            System.out.print(' ');
        }
        scan.close();
    }
    public static void mainsgdrfa(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        Integer[] in = new Integer[n];
        int[][] num = new int[n][2];
        for (int i = 1; i <= n; i++) {
            num[i - 1][0] = scan.nextInt();
            num[i - 1][1] = scan.nextInt();
            in[i - 1] = i;
        }
        for (int i = 0; i < m; i++) {
            if (num[i][0] == 1) {
                Arrays.sort(in, num[i][1] - 1, in.length);
            } else
                Arrays.sort(in, 0, num[i][1], (a, b) -> b - a);
        }
        for (int i : in) {
            System.out.print(i);
            System.out.print(' ');
        }
        scan.close();
    }

    public static void maingaedf(String[] args) {
        /*HashSet<HashMap<Integer,Integer>> set = new HashSet<>();
        set.add(new HashMap<>(1,2));
        set.add(new HashMap<>(1,3));*/
        //System.out.println(set.size());
        System.out.println(Math.sqrt(2021041820210418L));
    }
    public static final long MOD = (long) (1e9 + 7);
    public static long func(String s) {
        int n = s.length();
        long[][] dp = new long[n+2][n+2];
        dp[0][0] = 1;//辅助初始化，同时也可以具有实际意义
        for (int i = 1; i <= n; ++i){
            if (s.charAt(i-1) == '(') {
                for (int j = 1; j <= n; ++j) {  //读入左括号，不可能出现左与右相等的情况，从1开始
                    dp[i][j] = dp[i-1][j-1];
                }
            }else {
                dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % MOD;//dp[i][0]带公式越界，用原方法判定
                for (int j = 1; j <= n; ++j) {
                    dp[i][j] = (dp[i-1][j+1] + dp[i][j-1]) % MOD;
                }
            }
        }
        //从小往大括号数递增，第一个非零方案对应的状态就是最少括号数的”恰好“合法串
        for (int i = 0; i < n; ++i) {
            if (dp[n][i] != 0) return dp[n][i];
        }
        return -1;
    }
    public static void main1654(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long l = func(s);
        StringBuilder stringBuilder = new StringBuilder(s);
        stringBuilder.reverse();
        for (int i = 0; i < stringBuilder.length(); ++i) {
            if (stringBuilder.charAt(i) == '(') {
                stringBuilder.setCharAt(i, ')');
            }else {
                stringBuilder.setCharAt(i, '(');
            }
        }
        long r = func(stringBuilder.toString());
        System.out.println((l * r) % MOD);
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = 2000010;
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] a = new int[N];
        int[] l = new int[N];
        int[] r = new int[N];
        for (int i = 1; i <= n; ++i) {
            int x = scan.nextInt();
            a[i] = x;
            if (x < 0)
                l[-x]++;
            else if (x > 0)
                r[x]++;
        }

        for (int i = 1; i <= m; ++i) {
            l[i] += l[i - 1];
            r[i] += r[i - 1];
        }

        int res = 0;
        for (int i = 1; i <= m; ++i) {
            int s = l[i];
            if (m - i * 2 > 0)
                s += r[m - i * 2];
            res = Math.max(res, s);
        }

        for (int i = 1; i <= m; ++i) {
            int s = r[i];
            if (m - i * 2 > 0)
                s += l[m - i * 2];
            res = Math.max(res, s);
        }

        for (int i = 1; i <= n; ++i)
            if (a[i] == 0)res++;
        System.out.println(res);
    }
}
